﻿
    using Maticsoft.BLL;
    using Maticsoft.Model;

    using System;
    using System.Text;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class WebPage_DiaoCha_Wenti_Xuanxiang_Tianjia : SystemBBasePage
    {
     
        private Maticsoft.BLL.vote_options opt = new Maticsoft.BLL.vote_options();
        private Maticsoft.Model.vote_question qu = new Maticsoft.Model.vote_question();
        private Maticsoft.BLL.vote_question que = new Maticsoft.BLL.vote_question();

        private void getTitleName(int id)
        {
            StringBuilder builder = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            foreach (Maticsoft.Model.vote_question _question in this.que.GetModelList("id=" + id.ToString()))
            {
                builder.Append("<h2>'" + _question.Title + "'添加选项</h2>");
                builder2.Append("<input type='hidden' name='question_id' value='" + _question.id + "'/>");
            }
            this.Literal1.Text = builder.ToString();
            this.Literal2.Text = builder2.ToString();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.HeaderControl1.Select = "diaocha";
            this.DiaoCha1.Select = "Wenti";
            if (base.Request.QueryString["add"] != null)
            {
                this.ID = base.Request.QueryString["add"].ToString();
                if (this.ID != null)
                {
                    this.getTitleName(int.Parse(this.ID));
                }
            }
            if (base.Request.HttpMethod == "POST")
            {
                this.setContent();
            }
        }

        private void setContent()
        {
            Maticsoft.Model.vote_options model = new Maticsoft.Model.vote_options();
            model.question_id = int.Parse(base.Request.Form["question_id"].ToString());
            model.name = base.Request.Form["name"].ToString();
            model.is_br = int.Parse(base.Request.Form["is_br"].ToString());
            model.is_input = int.Parse(base.Request.Form["is_input"].ToString());
            model.is_show = int.Parse(base.Request.Form["is_show"].ToString());
            model.order = int.Parse(base.Request.Form["order"].ToString());
            this.opt.Add(model);
            base.Response.Redirect("DiaoCha_Wenti_Xuanxiang.aspx?id=" + this.ID);
        }

        private string ID
        {
            get
            {
                return this.ViewState["ID"].ToString();
            }
            set
            {
                this.ViewState["ID"] = value;
            }
        }
    }


